<include file="App/Home/View/Public/header.html"/>
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">			
		<div class="row">
			<ol class="breadcrumb">
				<li class="active position_tit">充值管理<span style=" padding:0px 5px;">/</span>充值</li>
			</ol>
		</div><!--/.row-->
		
		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-heading">充值<span></span></div>
					<div class="panel-body">
                    <form action="{:U('Pay/do_chongzhi')}" method="post">
					  <table class="table2 card_input" style=" border-collapse: inherit;">
                            <tbody>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">充值金额：</td>
                                <td class="left1 td2" style=" padding-left: 0px;"><input style=" width:300px;" class="form-control" Placeholder="" id="money" onBlur="checkout_money()" name="money"></td>
                                <td class="left1 td3"><span>最小充值金额<span id="mins">{$mins}</span>元</span></td>
                              </tr>
                                <td class="right1 td1" style=" padding-right:0px;">充值币种：</td>
                                <td class="left1 td2" style=" padding-left: 0px;">
                                  <select style="width:300px; border-radius:4px; border:1px solid #eee; padding:6px 8px;" id="currency">
                                    <option>请选择币种</option>
									<foreach name="currency_name" item="currency">
                                    <option value="{$currency['currency_id']}">{$currency['currency_name']}</option>
									</foreach>
                                  </select>
                                </td>
                              </tr>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">汇出人姓名：</td>
                                <td class="left1 td2" style=" padding-left: 0px;"><input style=" width:300px;" class="form-control" disabled="disabled" value="{$name}"></td>
                                <td class="left1 td3"><span>系统只接受您实名账户充值</span></td>
                              </tr>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">汇出银行：</td>
                                <td class="left1 td2" style=" padding-left: 0px;">
                                  <select style="width:300px; border-radius:4px; border:1px solid #eee; padding:6px 8px;" id="bank">
                                    <option>请选择银行</option>
									<foreach name="bank" item="bank">
                                    	<option value="{$bank['id']}">{$bank['name']}</option>
									</foreach>
                                  </select>
                                </td>
                                <td class="left1 td3"><span>请注意：部分银行周末汇款不能及时到账</span></td>
                              </tr>
                              <tr>
                                <td class="right1 td1" style=" padding-right:0px;">汇款银行账号：</td>
                                <td class="left1 td2" style=" padding-left: 0px;"><input style=" width:300px;" class="form-control" id="card_num" onBlur="checkout_num()"></td>
                                <td class="left1 td3"><span class="red">请准确填写汇款银行账号，否则无法到账</span></td>
                              </tr>
							    </tr>
                                <td class="right1 td1" style=" padding-right:0px;">请选择汇款银行：</td>
                                <td class="left1 td2" style=" padding-left: 0px;">
                                  <select style="width:300px; border-radius:4px; border:1px solid #eee; padding:6px 8px;" id="banks">
								   <option value="">请选择银行</option>
									<foreach name="banks" item="vo">
                                    <option value="{$vo['bank_id']}">{$vo['bank_name']}</option>
									</foreach>
                                  </select>
                                </td>
								<td><span id="b_card" style="display:none"></span></td>
                              </tr>
                            </tbody>
						</table>
                    </form>
                        <div class="panel-footer">
						<div class="input-group article_btn">
							<span class="input-group-btn">
								<button class="btn btn-success btn-md btn_art_return" onClick="do_chongzhi()">确认充值</button>
							</span>
						</div>
					</div>	
					</div>
				</div>
			</div>
		</div><!--/.row-->
        <div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-heading">充值记录</div>
					<div class="panel-body">
						<table class="table_all">
						    <thead>
						      <tr>
						        <th class="th_sty">用户名</th>
                                <th class="th_sty">用户真实姓名</th>
                                <th class="th_sty">充值金额</th>
                                <th class="th_sty">汇出银行</th>
                                <th class="th_sty">汇出卡号</th>
                                <th class="th_sty">充值币种</th>
                                <th class="th_sty">汇款到银行</th>
                                <th class="th_sty">汇款持卡人姓名</th>
                                <th class="th_sty">汇款到卡号</th>
                                <th class="th_sty">状态</th>
						      </tr>
						    </thead>
                            <tbody>
							<foreach name="pay" item="pay">
                              <tr>
                                <td>{$Think.session.USER_KEY}</td>
                                <td>{$pay['member_name']}</td>
                                <td>{$pay['money']}</td>
                                <td>{$pay['bank_name']}</td>
                                <td>{$pay['account']}</td>
                                <td>{$pay['currency_name']}</td>
                                <td>{$pay['b_bank']}</td>
                                <td>{$pay['bank_adddress']}</td>
                                <td>{$pay['bank_no']}</td>
                                <td>{$pay['status']|checkout_status=###}</td>
                              </tr>
							</foreach>
                            </tbody>
						</table>
                        
					</div>
				</div>
			</div>
			
							{$page}
		</div><!--/.row-->
	</div>	<!--/.main-->	
<script src="__PUBLIC__/Home/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
	$("#banks").change(function(){
		 var url = "{:U('Pay/select_bank')}"
		 var ob = $(this);
         ob.nextAll("select").remove();
			 $.post(url,{'bank_id':ob.val()},function(data){
					console.log(data);
					var span ='持卡人姓名:'+data['bank_adddress']+"卡号:"+data['bank_no'];
					$('#b_card').html(span);
					$('#b_card').css('display','block');
			 })
	})
   function checkout_money(){
   		var num= $('#money').val();
		//alert(num);
		if(num == ''){
			alert("请输入充值金额");
			return;
		}else if(isNaN(num)){
			alert("请输入数字类型的金额");return;
		}
   		var money = parseFloat($('#money').val());
		var mins = parseFloat($('#mins').html());
		if(isNaN($('#money').val())){
			alert("不能含有非数字字段");
		}
		if(money<mins){
			alert("未达到最小充值金额");
		}
   }
   function do_chongzhi(){
   	
   	//	
		if(isNaN($('#currency').val()) ){
			alert("请选择充值币种的种类");return;
		}
		if(isNaN($('#bank').val()) ){
			alert("请选择银行");return;
		}
   		var num= $('#money').val();
		
		if(num==''){
			alert("请输入充值金额");return;
		}else if(!isNaN(num)){
			var money = parseFloat(num);
		}else{
			alert("请输入数字类型的金额");return;
		}
		
		if($('#card_num')==""){
			alert("请输入正确的银行卡号");return;
		}
		
   		if(isNaN($('#money').val()) || isNaN($('#card_num').val())){
			alert("请检查输入银行卡号或者金额是否符合标准");return;
		}
			var bank = $('#bank').val();
			var currency = $('#currency').val();
			var card_num = $('#card_num').val();
			var b_card = $('#banks').val();
			var url = "{:U('Pay/do_chongzhi')}";
			$.ajax({
				url:url,
				type:'post',                     //发送方式
	            data:{'bank':bank,'money':money,'currency_id':currency,'account':card_num,'b_card':b_card},          //请求数据
	            async:true,                     //是否同步
	            dataType:'json',                //响应的数据类型
	            success:function(data){         //成功回调函数
					if(data['status']==1){
						alert(data['info']);
						window.location.reload();
					}else{
						alert(data['info']);
					}
	            },
				error:function(){
					alert("请求超时");
				}
			})
   }
   function checkout_num(){
   		var num = $('#card_num').val();
		if(isNaN(num)){
			alert("请输入正确的银行卡号，不能含有非数字");
		}
   }
</script>

</html>

